package cn.edu.ecut.synchronize;

public class JdbcHelper {
	
	private boolean open = true ;
	
	public static JdbcHelper getInstance() {
		JdbcHelper h = new JdbcHelper();
		return h ;
	}
	
	// 对于实例方法来说，同步锁就是 当前实例
	public synchronized void release() {
		System.out.println( Thread.currentThread().getName() + " : " + this.isOpen() );
		open = false ;
		System.out.println( Thread.currentThread().getName() + " : " + this.isOpen() );
	}
	
	/*
	public void release() {
		synchronized( this ) { 
			System.out.println( Thread.currentThread().getName() + " : " + this.isOpen() );
			open = false ;
			System.out.println( Thread.currentThread().getName() + " : " + this.isOpen() );
		}
	}
	*/
	
	public boolean isOpen() {
		return open ;
	}

}
